package com.lineage.data.item_etcitem.add;

import com.lineage.config.ConfigGuaji;
import com.lineage.data.executor.ItemExecutor;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class guaji_count extends ItemExecutor {
  private static final Log _log = LogFactory.getLog(guaji_count.class);
  
  private int _type1;
  
  private int _type2;
  
  public static ItemExecutor get() {
    return new guaji_count();
  }
  
  public void execute(int[] data, L1PcInstance pc, L1ItemInstance item) {
    if (pc.getguaji_count() + this._type1 > ConfigGuaji.guaji_check) {
      pc.sendPackets((ServerBasePacket)new S_ServerMessage("无法领取.活力值上限值:" + ConfigGuaji.guaji_check));
      return;
    } 
    pc.setguaji_count(pc.getguaji_count() + this._type1);
    pc.sendPackets((ServerBasePacket)new S_SystemMessage("获得" + this._type1 + "点活力值。"));
    if (this._type2 == 1)
      pc.getInventory().removeItem(item, 1L); 
  }
  
  public void set_set(String[] set) {
    try {
      this._type1 = Integer.parseInt(set[1]);
    } catch (Exception exception) {}
    try {
      this._type2 = Integer.parseInt(set[2]);
    } catch (Exception exception) {}
  }
}
